package com.wander.juc.thread;

public class JoinExample {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(()->{
            try {
                Thread.sleep(1000);
                System.out.println(Thread.currentThread().getName() + " end.");
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        });
        Thread t2 = new Thread(()->{
            try {
                Thread.sleep(3000);
                System.out.println(Thread.currentThread().getName() + " end.");
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        });
        t1.start();
        t2.start();
        t1.join();
        t2.join(1000);
        System.out.println(Thread.currentThread().getName() + " end.");
    }
}
